package com.luxsoft.sw3.services;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.luxsoft.sw3.replica.Validacion;

@Service("replicaValidationManager")
@Transactional(propagation=Propagation.SUPPORTS,readOnly=true)
public class ReplicaValidationManagerImpl implements ReplicaValidationManager{
	
	@Autowired
	private HibernateTemplate hibernateTemplate;

	public ReplicaValidationManagerImpl() {				
	}

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void eliminar(Validacion v) {
		this.hibernateTemplate.delete(v);
		
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public Validacion salvar(Validacion v) {
		v.setActualizacion(new Date());
		return (Validacion)this.hibernateTemplate.merge(v);
	}

	

	
}
